home *** CD-ROM | disk | FTP | other *** search
- /*_________________________________________________________________________________
-
- XTIShellADev.c
-
- Apple Computer, Inc.
- Copyright (C) 1992,1993. All rights reserved.
-
- Main C code for user interface portion of the XTI Shell adev. This file is
- really meant to be a shell in the truest sense of the word. There is not a
- lot of code here, except for the MGetADev routine, but more just place holders
- for your interface code.
-
- Revision History:
-
- __________________________________________________________________________________*/
-
- #include "XTIShell.h"
-
- /* ___ Defines ___ */
- //
- // Fill in the height of your interface window here
- //
- #define kXTIWindHeight 200
-
-
- /* ___ MGetAdev Locals (must be 8 bytes)___ */
- typedef struct XTIMGetLocals {
- short devInd;
- Boolean onlySlot;
- char filler;
- short mask;
- char nextPort;
- char nextSlot;
- } XTIMGetLocals, *XTIMGetLocalsPtr;
-
- /*______________________________________________________________________________
- MGetADEV
-
- This routine gets method based ADEV port information. It currently will
- bring up the XTI Shell icon under the modem and printer ports. It must be
- modified to display a method icon under the appropriate device for your link.
-
- Returns: status, 0 for valid information ,1 for no more information or
- error.
-
- Parameters: <-> aRecPtr ADev record pointer
-
- Note: If adev signature size is 0, then first time.
- adevLocals use XTIMGetLocals struct.
- ______________________________________________________________________________*/
-
- #define kPrinterDev 1 /* 4th byte of signature, device/slot */
- #define kModemDev 2
-
- char MGetADEV(TAdevRecPtr aRecPtr)
- {
- register TAdevItemPtr myItemPtr;
- register XTIMGetLocalsPtr rtLocPtr = (XTIMGetLocalsPtr)aRecPtr->adevLocals;
- Handle tempIconHdl,
- tempStrHdl;
- short iconResId,
- strResId;
- char thisPort,
- thisSlot;
- char returnVal = noErr;
-
- if (!aRecPtr->adevID.aidSize) {
- rtLocPtr->devInd = 0; /* so that first one is modem */
- rtLocPtr->onlySlot = false;
- }
-
- /* fill ADevRec with port information */
- /* ___ Port/Slot Counter (device indicator)___ */
- rtLocPtr->devInd++;
-
- /* ___ Device ___ */
- myItemPtr = &aRecPtr->adevDevice;
- myItemPtr->itemFlags = 0;
- switch (rtLocPtr->devInd) {
- case kModemDev: /* MODEM PORT */
- myItemPtr->itemRef = kBuiltInRef | kModemPort;
- iconResId = kModemIconRes;
- strResId = kModemStrRes;
- myItemPtr->itemFlags |= kExclusFlagMask; /* Modem port is used exclusively */
- break;
- case kPrinterDev: /* PRINTER PORT */
- myItemPtr->itemRef = kBuiltInRef | kPrinterPort;
- iconResId = kPrinterIconRes;
- strResId = kPrintStrRes;
- myItemPtr->itemFlags |= kExclusFlagMask; /* Printer port is used exclusively */
- break;
- default:
- returnVal = kMGetNoMore;
- goto mGetADEVEx;
- break;
- }
- tempIconHdl = Get1Resource( 'ICON', iconResId );
- if (ResError() || !tempIconHdl) {
- returnVal = kMFatalErr;
- goto mGetADEVEx;
- }
- tempStrHdl = Get1Resource( 'STR ', strResId );
- if (ResError() || !tempStrHdl) {
- returnVal = kMFatalErr;
- goto mGetADEVEx;
- }
-
- myItemPtr->itemIcon = tempIconHdl;
- myItemPtr->itemStr = (StringHandle)tempStrHdl;
- myItemPtr->itemFlags |= kInfoFlagMask;
-
- /* ___ Port ___ */
- myItemPtr = &aRecPtr->adevPort;
- myItemPtr->itemFlags = 0;
- switch (rtLocPtr->devInd) {
- case kModemDev:
- thisPort = 0;
- thisSlot = kModemPort;
- break;
- case kPrinterDev:
- thisPort = 0;
- thisSlot = kPrinterPort;
- break;
- default:
- break;
- }
- myItemPtr->itemIcon = tempIconHdl;
- myItemPtr->itemStr = (StringHandle)tempStrHdl;
-
-
- /* ___ Method ___ */
- myItemPtr = &aRecPtr->adevMethod;
- myItemPtr->itemFlags = 0;
- myItemPtr->itemRef = kXTIShellRef;
- tempIconHdl = Get1Resource( 'ICON', kRemoteIconRes );
- if (ResError() || !tempIconHdl) {
- returnVal = kMGetNoMore;
- goto mGetADEVEx;
- }
- myItemPtr->itemIcon = tempIconHdl;
- tempStrHdl = Get1Resource( 'STR ', kRemoteStrRes );
- if (ResError() || !tempStrHdl) {
- returnVal = kMGetNoMore;
- goto mGetADEVEx;
- }
- myItemPtr->itemStr = (StringHandle)tempStrHdl;
- myItemPtr->itemFlags = kInfoFlagMask;
-
- /* ___ Adev ID ___ */
- aRecPtr->adevID.aidSize = 1; /* number of longs */
- ((TADEVSigRecPtr)(aRecPtr->adevID.aidData))->id = 'XX';
- ((TADEVSigRecPtr)(aRecPtr->adevID.aidData))->port = thisPort;
- ((TADEVSigRecPtr)(aRecPtr->adevID.aidData))->slot = thisSlot;
-
-
- mGetADEVEx:
- return( returnVal );
-
- }
-
- /*______________________________________________________________________________
- MAGetAttribs - Get attributes of window to determine the height necesary.
-
- Returns: status, 0 for no err, -1 for insufficient drawing height
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
-
- char MAGetAttribs(TAdevWindPtr awPtr)
-
- {
- char returnVal = noErr;
-
- if (awPtr->awRect.bottom < kXTIWindHeight) {
- returnVal = kMInsufDrawHt;
- }
- else {
- awPtr->awRect.bottom = kXTIWindHeight; /* window height */
- awPtr->awMessage = kXTIMinBufSize; /* min buf size */
- }
-
- return( returnVal );
-
- }
-
- /*______________________________________________________________________________
- XTIINIT - Initialize local variables in preparation for editing.
-
- Returns: status, 0 for no err, -1 for initialization error
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAInit(TAdevWindPtr awPtr)
-
- {
-
- //
- // This is the routine where you should do things like creating Text Edit
- // boxes, radio buttons, etc. Set these things to their initial values
- // based on the values in the awConfig record passed in.
- //
- return( noErr );
- }
-
-
- /*______________________________________________________________________________
- MAKill - Dispose local variables and terminate editing of config data
-
- Returns: status, 0 for no err, -1 for can't close right now
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAKill(TAdevWindPtr awPtr)
-
- {
- //
- // Dispose of any memory allocated.
- //
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAActivate - Perform activation/deactivation for the Port Info window. Handle
- special case of router active or not.
-
- Returns: status, 0 for no err,-1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- Note: The text edit should be active with an activate event and if the router is not
- running.
-
- ______________________________________________________________________________*/
-
- char MAActivate(TAdevWindPtr awPtr)
-
- {
- //
- // Do whatever needs to be done to activate or deactivate your window.
- //
-
- return( noErr );
- }
-
-
- /*______________________________________________________________________________
- MAClick - Called whenever a mousedown occurs in the port's drawing area,
- this routine determines if any further action is required.
-
- Returns: status, 0 for no err,-1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAClick(TAdevWindPtr awPtr)
- {
- //
- // Process the mouse click.
- //
- return ( noErr );
- }
-
- /*______________________________________________________________________________
- MADraw - Draw the contents the port editing rect, except for controls.
- All controls are drawn by the calling routine.
-
- Returns: status, 0 for no err,-1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- Note: Handle special case of router active
-
- ______________________________________________________________________________*/
-
-
- char MADraw(TAdevWindPtr awPtr)
- {
- //
- // Draw the window. If the router is running, configuration items should be
- // grayed out so the user does not think they can be modified.
- //
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAMessage - Edit the contents of text edit field, if any, and
- change router status
-
- Returns: status, 0 for no err, -1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAMessage(TAdevWindPtr awPtr)
- {
- //
- // Respond to the following messages:
- //
- switch (awPtr->awMessage) {
- case kUndoEvt:
- //
- // Process the undo for the current text edit.
- //
- case kCutEvt:
- break;
- //
- // Process the cut for the current text edit.
- //
- break;
- case kCopyEvt:
- //
- // Process the copy for the current text edit.
- //
- break;
- case kPasteEvt:
- //
- // Process the paste for the current text edit.
- //
- break;
- case kClearEvt:
- //
- // Process the clear for the current text edit.
- //
- break;
- case kRouterInact:
- //
- // Process the router inactivate event.
- //
- break;
- case kRouterAct:
- //
- // Process the router activate event.
- //
- break;
- }
-
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAIdle - Update the window if no other event (Call TEIdle)
-
- Returns: status, 0 for no err,-1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAIdle(TAdevWindPtr awPtr)
- {
- //
- // Process an idle event for the window.
- //
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAKey - Process a key-down event if you have an active TextEdit field
-
- Returns: status, 0 for no err,-1 for fatal err
-
- Parameters: <-> awPtr ADev window pointer
-
- Note: Password text edit box actually is two boxes mirrored.
- ______________________________________________________________________________*/
-
-
- char MAKey(TAdevWindPtr awPtr)
- {
- //
- // Process a key event in your window.
- //
- return( noErr );
- }
-
-
- /*______________________________________________________________________________
- MASelectTE - Activate the TextEdit field indicated
-
- Returns: status, 0 for no err,-1 for cannot deactiv the current TE field
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
-
- char MASelectTE(TAdevWindPtr awPtr)
- {
- //
- // Deactivate the current text edit and activate the specified one.
- //
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAGetConfig - Get the current contents of the config editing fields
-
- Returns: status, 0 for no err,-1 for invalid config field data
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAGetConfig(TAdevWindPtr awPtr)
- {
- //
- // Fill in the awConfig record based on the user configuration
- //
- return( noErr );
- }
-
- /*______________________________________________________________________________
- MAGetLine - Get a line of the current configuration
-
- Returns: status, 0 for no err,-1 for no more lines
-
- Parameters: <-> awPtr ADev window pointer
-
- ______________________________________________________________________________*/
-
- char MAPrint(TAdevWindPtr awPtr)
- {
- //
- // Fill the summary string with one line of the current configuration.
- // This routine will be called repeatedly until you indicate that
- // there are no more lines.
- //
- return( noErr );
- }
-
-